package o;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import androidx.annotation.NonNull;
import com.huawei.appmarket.service.appmgr.bean.ApkInstalledInfo;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class dsx extends dta {
    private static final Executor ˎ = Executors.newFixedThreadPool(1);

    protected /* synthetic */ Object doInBackground(Object[] objArr) {
        return ॱ((e[]) objArr);
    }

    public static void ˏ(e eVar) {
        new dsx().executeOnExecutor(ˎ, new e[]{eVar});
    }

    protected Boolean ॱ(e... eVarArr) {
        if (eVarArr != null && eVarArr.length > 0 && e.REFRESH_DATA == eVarArr[0]) {
            Logger.ˎ("GetInstalledAppTask", "refresh InstalledList");
        } else if (dtd.ˎ().ˏ()) {
            return Boolean.valueOf(false);
        } else {
            Logger.ˎ("GetInstalledAppTask", "getAllInstalledList");
        }
        return Boolean.valueOf(ˏ());
    }

    private boolean ˏ() {
        try {
            dtd.ˎ().ˏ(ॱ());
            return true;
        } catch (Throwable e) {
            Logger.ˋ("GetInstalledAppTask", "getApkInstalledInfos failed.", e);
            return false;
        }
    }

    @NonNull
    private List<ApkInstalledInfo> ॱ() throws Exception {
        int i;
        List<ApkInstalledInfo> arrayList = new ArrayList();
        PackageManager packageManager = ContentManager.getInstant().getContext().getPackageManager();
        boolean ˋ = eqh.ˎ().ˋ();
        if (ˋ) {
            i = 8192;
        } else {
            i = 0;
        }
        try {
            List<PackageInfo> installedPackages = packageManager.getInstalledPackages(i);
            if (installedPackages != null) {
                Logger.ˎ("GetInstalledAppTask", "getApkInstalledInfos");
                for (PackageInfo packageInfo : installedPackages) {
                    if (!(ContentManager.getInstant().getContext().getPackageName().equals(packageInfo.packageName) || "com.huawei.android.hsf".equals(packageInfo.packageName))) {
                        if ((eqh.ˎ().ˏ() || (packageInfo.applicationInfo.flags & 8388608) != 0) && dsz.ॱ(packageInfo.applicationInfo)) {
                            ApkInstalledInfo apkInstalledInfo = new ApkInstalledInfo();
                            if (ˋ && (packageInfo.applicationInfo.flags & 8388608) == 0) {
                                apkInstalledInfo.ˊ(false);
                            }
                            apkInstalledInfo.ॱ(packageInfo.applicationInfo.loadLabel(packageManager).toString());
                            apkInstalledInfo.ˏ(packageInfo.packageName);
                            String str = packageInfo.applicationInfo.sourceDir;
                            if (str == null) {
                                Logger.ˎ("GetInstalledAppTask", packageInfo.packageName + " applicationInfo.sourceDir null");
                            } else {
                                long length = new File(str).length();
                                apkInstalledInfo.ॱ(length);
                                apkInstalledInfo.ˎ(epw.ˊ(length));
                                apkInstalledInfo.ˋ(packageInfo.lastUpdateTime);
                                apkInstalledInfo.ˊ(erw.ˏ(packageManager, packageInfo.packageName));
                                arrayList.add(apkInstalledInfo);
                            }
                        }
                    }
                }
            }
            return arrayList;
        } catch (Exception e) {
            Logger.ˎ("GetInstalledAppTask", "getInstalledPackages Exception:" + e.toString());
            throw e;
        }
    }
}
